const fs = require('fs');
const path = require('path');
fs.readFile(path.join(__dirname,'./file/成绩.txt',),'utf-8',(err,data) => {
    if(err) return console.log('读取文件失败');
    console.log(data);
    const scoreArr = data.split(' ');
    // console.log(scoreArr);
    let str = '';
    scoreArr.forEach((item,i) => {
        if(item.length > 0) {
            // console.log(item);
            const result = item.split('=');
            // console.log(result);
            const newScore = result[0] + ':' + result[1] + '\n';
            console.log(newScore);
            str += newScore;
        }
    })
    fs.writeFile(path.join(__dirname,'./file/成绩ok.txt'),str,(err) => {
        if(err) return console.log('写入成绩失败'+ err.message);
        console.log('写入成绩成功');
    })
})